function init() {
  let s = decodeURI(location.href.split('?')[1])
  const arr = s.split('&')
  arr.forEach(item => {
    const a = item.split('=')
    if (a[0] === 'jid') {
      obj.jid = a[1]
    } else if (a[0] === 'jobName') {
      obj.jobName = a[1]
    } else {
      obj.deptId = a[1]
    }
  })
  $('#jobName').val(obj.jobName)
}

function getDept() {
  axiosRequest1("get", "/dept/deptList").then(res => {
    const {
      code,
      data,
      message
    } = res.data
    if (code === 200) {
      let str = '<option value=0>请选择部门</option>'
      data.forEach(item => {
        str += `<option value='${item.deptId}'>${item.deptName}</option>`
      })
      $('#deptSelect').html(str)
      $('#deptSelect').val(obj.deptId)
    } else {
      showMessage(message, 2000)
    }
  }, error => {
    console.log(error);
  })
}

function save() {
  let jobName = $('#jobName').val().trim()
  let deptId = $('#deptSelect').val()
  if (jobName === '') {
    showMessage("请输入职位名称", 2000)
    return
  }
  if (deptId == 0) {
    showMessage("请选择部门", 2000)
    return
  }
  if (jobName == obj.jobName && deptId == obj.deptId) {
    showMessage('请作出修改', 2000)
    return
  }
  let object = { jobId: obj.jid, jobName, jobDeptId: deptId }
  axiosRequest1('post', '/job/update', object).then((result) => {
    const { data, code, message } = result.data
    showMessage(message, 2000)
  }).catch((err) => {
    console.log(err);
  });
}